#pragma once
#include "entt.hpp"
#include "Scene.h"
namespace Orange {

	class Entity {
	public:
		Entity() = default;
		Entity(entt::entity entity, Scene* scene);
		Entity(const Entity& other) = default;

		template <typename T , typename... Args>
		T& AddComponent(Args&&... args) {
			return m_Scene->m_Register.emplace<T>(m_EntityHandle, std::forward<Args>(args)...);
		}

		template <typename T>
		T& GetComponent() {
			return m_Scene->m_Register.get<T>(m_EntityHandle);
		}

		template <typename T>
		bool HasComponent() {
			return m_Scene->m_Register.all_of<T>(m_EntityHandle);
		}

		template <typename T>
		void RemoveComponent() {
			 m_Scene->m_Register.remove<T>(m_EntityHandle);
		}

		operator bool() {
			return m_EntityHandle != entt::null;
		}
		operator uint32_t() {
			return uint32_t(m_EntityHandle);
		}
		operator entt::entity() const {
			return m_EntityHandle;
		}
		
		bool operator==(const Entity& other) {
			return other.m_EntityHandle == m_EntityHandle && other.m_Scene == m_Scene;
		}

		bool operator!=(const Entity& other) {
			return !(*this == other);
		}

	private:
		entt::entity m_EntityHandle{ entt::null };
		Scene* m_Scene = nullptr;
	};
}